function [spectrum,background] = relcorrect(x,y,e0,tth)
% return relativistic correction according to Ribberfors and Holm

% For the extraction of the valence Compton contribution the experimental
% Compton profile J(pz) has to be calculated from the DDSCS. In the 
% non-relativistic limit the Compton profile J(pz) is directly proportional 
% to the DDSCS [see equation (3)]. In the relativistic case it needs to be 
% corrected according to Ribberfors (1975) and Holm (1988)


%INPUT: x = x-vector
%       y = y-vector
%       e0= analyzer energy
%      tth= scattering angle [deg two theta]
%OUTPUT: spectrum = corrected spectrum
%        background = background
%depends on e2pz.m

[pz,background] = e2pz(x*1e-3+e0,e0,tth);

background = background*max(abs(1./background));

spectrum = y.*background;
